package com.qianxunclub.util;

import java.io.Serializable;
import java.util.List;

/**
 * Created by zhangbin on 2017/2/21.
 */
public class PageDataResponse<T> implements Serializable {
    protected Integer limit;
    protected Integer offset;
    protected Integer total = Integer.valueOf(0);
    protected Integer returnCode = Integer.valueOf(1000);
    protected String message;
    protected List<T> pageData;
    protected boolean success;

    public PageDataResponse() {
        this.setReturn(ReturnCode.CODE_1000);
    }

    public void setReturn(ReturnCode returnCode){
        this.returnCode = returnCode.code();
        this.message = returnCode.message();
    }

    public Integer getLimit() {
        return limit;
    }

    public void setLimit(Integer limit) {
        this.limit = limit;
    }

    public Integer getOffset() {
        return offset;
    }

    public void setOffset(Integer offset) {
        this.offset = offset;
    }

    public Integer getReturnCode() {
        return this.returnCode;
    }

    public void setReturnCode(Integer returnCode) {
        this.returnCode = returnCode;
    }

    public String getMessage() {
        return this.message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public List<T> getPageData() {
        return this.pageData;
    }

    public void setPageData(List<T> pageData) {
        this.pageData = pageData;
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    public boolean isSuccess(){
        if(returnCode.equals(Integer.valueOf(1000))){
            this.success = true;
            return this.success;
        }
        this.success = false;
        return this.success;
    }
}
